package com.xwm93up.basic.lambdatips.Sorted;

import com.xwm93up.basic.lambdatips.Student;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

/**
 * @Description: 与List.sort一起使用
 * @Author: xwm93up
 * @Since: 2022/4/19 14:00
 */
public class CollectionsSortDemo3 {
    public static void main(String[] args) {
        List<Integer> numList = Arrays.asList(12, 10, 15, 8, 11);
        numList.sort(Comparator.naturalOrder());
        numList.forEach(n -> System.out.println(n + " "));
        System.out.println("\n-----------");

        List<String> strList = Arrays.asList("Varanasi", "Allahabad", "Kanpur", "Noida");
        strList.sort(Comparator.naturalOrder());
        strList.forEach(s -> System.out.print(s + " "));
        System.out.println("\n-----------");

        List<Student> stdList = Student.getStudentList();
        stdList.sort(Comparator.naturalOrder());
        stdList.forEach(s -> System.out.print(s.getName() + " "));
    }
}
